<template>
  <div class="dashboard-chart-line" ref="line"></div>
</template>

<script>
import * as echarts from 'echarts'
import resize from '@/mixin/resize'

export default {
  name: 'ChartLine',
  mixins: [resize],
  mounted() {
    const myEcharts = echarts.init(this.$refs.line)
    myEcharts.setOption({
      xAxis: {
        show: false,
        data: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
      },
      yAxis: {
        show: false
      },
      series: {
        type: 'line',
        data: [
          120,
          100,
          40,
          130,
          180,
          110,
          30,
          70,
          100,
          60,
          190,
          160,
          140,
          90,
          20,
          40
        ],
        // 折线圆滑
        smooth: true,
        // 去除折点
        itemStyle: {
          opacity: 0
        },
        // 区域填充颜色
        areaStyle: {
          color: {
            type: 'linear',
            x: 0,
            y: 0,
            x2: 0,
            y2: 1,
            colorStops: [
              {
                offset: 0,
                color: '#975FE4' // 0% 处的颜色
              },
              {
                offset: 1,
                color: '#fff' // 100% 处的颜色
              }
            ],
            global: false // 缺省为 false
          }
        },
        // 线条颜色
        lineStyle: { color: '#975FE4' }
      },
      // 图表位置
      grid: {
        // show: false,
        left: -10,
        right: -10,
        top: 0,
        bottom: 0
      }
    })
    this.myEcharts = myEcharts
  }
}
</script>

<style lang="scss" scoped>
.dashboard-chart-line {
  width: 100%;
  height: 100%;
}
</style>
